package com.gomore.opple.module.main.good.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gomore.opple.R;
import com.gomore.opple.common.GlobalConstant;
import com.gomore.opple.model.SecondFilter;

import java.util.List;

import de.greenrobot.event.EventBus;

/**
 * Created by asus on 2017/5/13.
 */
public class TypeNameAdapter extends BaseAdapter {

    Context mContext;
    List<String> mListData;

    public TypeNameAdapter(Context context, List<String> listData) {
        this.mContext = context;
        this.mListData = listData;
    }

    @Override
    public int getCount() {
        return mListData.size();
    }

    @Override
    public Object getItem(int position) {
        return mListData == null ? 0 : mListData.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.filter_list_item, parent, false);
            viewHolder.filter_text = (TextView) convertView.findViewById(R.id.filter_text);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.filter_text.setText(mListData.get(position));
        return convertView;
    }

    private static class ViewHolder {
        TextView filter_text;
    }
}